﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataSet QueryQPPROF(DataRow dwData, int option = 1)
        {
            DataSet SReturn = new DataSet();
            DataSet SResult = new DataSet();
            OracleCommand or1;
        
                or1 = OracleDB.CreateCommand();
                switch (option)
                {
                    case 2:
                        or1.CommandText = "SELECT DISTINCT GS.* FROM EKPOS GA LEFT JOIN QPPROF GS ON EKPMANDANT=QAPMANDANT"
                        + " AND utl_raw.cast_to_varchar2(EKPART)=QAPART"
                        + "  AND utl_raw.cast_to_varchar2(EKPVAR)=QAPVAR"
                        + "  WHERE EKPSA='PO' AND EKPARTGR=1 AND EKPMANDANT=:EKPMANDANT AND  EKPAUFKRS=:EKPAUFKRS AND EKPAUFLFD=:EKPAUFLFD ";
                        or1.Parameters.Add("EKPMANDANT", OracleType.NVarChar).Value = dwData["EKPMANDANT"].ToString();
                        or1.Parameters.Add("EKPAUFKRS", OracleType.NVarChar).Value = dwData["EKPAUFKRS"].ToString();
                        or1.Parameters.Add("EKPAUFLFD", OracleType.NVarChar).Value = dwData["EKPAUFLFD"].ToString();
                        break;
                }

                SResult = Connect2Proxy(or1);
                if (SResult.Tables.Count > 0)
                {
                    SResult.Tables[0].TableName = "QPPROF";
                    SReturn.Merge(SResult);
                } 
            return SReturn;
        }
    }
}
